package com.zyl.blog.CogniSphere.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Arrays;
import java.util.List;

/**
 * @version v1.0
 * @ProjectName: Personal_Blog_Server
 * @Package: com.zyl.blog.CogniSphere.model
 * @ClassName: SparkRequest
 * @Description: 星火AI请求实体
 * @Author FinalFantasy
 * @Date 2025/8/15-10:40
 */
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class SparkRequest {

    /**
     * 请求头
     */
    private Header header;

    /**
     * 请求参数
     */
    private Parameter parameter;

    /**
     * 请求体
     */
    private Payload payload;

    @Data
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    @Accessors(chain = true)
    public static class Header {

        /**
         * 应用ID
         */
        private String app_id;

        /**
         * 应用密钥
         */
        private String api_key;

        /**
         * 请求领域
         */
        private String domain;
    }

    @Data
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    @Accessors(chain = true)
    public static class Parameter {

        /**
         * 请求类型
         */
        private String model;
    }

    @Data
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    @Accessors(chain = true)
    public static class Payload {

        /**
         * 请求内容
         */
        private Message message;
    }

    @Data
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    @Accessors(chain = true)
    public static class Message {

        /**
         * 内容
         */
        private List<Content> text;
        public Message(Content... contents) {
            this.text = Arrays.asList(contents);
        }
    }

    @Data
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    @Accessors(chain = true)
    public static class Content {
        /**
         * "role": "user" 或 "assistant"
         */
        private String role;

        /**
         * "content": "消息内容"
         */
        private String content;
    }
}
